<?php
namespace Modules\Mall\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Modules\Mall\Entities\Slider;
use Modules\Mall\Http\Requests\SliderRequest;
class SliderController extends Controller
{
    //显示列表
    public function index()
    {
        $data = Slider::paginate(10);
        return view('mall::slider.index', compact('data'));
    }

    //创建视图
    public function create(Slider $slider)
    {
        return view('mall::slider.create',compact('slider'));
    }

    //保存数据
    public function store(SliderRequest $request,Slider $slider)
    {
        $slider->fill($request->all());
        $slider->save();

        return redirect('/mall/slider')->with('success', '保存成功');
    }

    //显示记录
    public function show(Slider $field)
    {
        return view('mall::slider.show', compact('field'));
    }

    //编辑视图
    public function edit(Slider $slider)
    {
        return view('mall::slider.edit', compact('slider'));
    }

    //更新数据
    public function update(SliderRequest $request, Slider $slider)
    {
        $slider->update($request->all());
        return redirect('/mall/slider')->with('success','更新成功');
    }

    //删除模型
    public function destroy(Slider $slider)
    {
        $slider->delete();
        return redirect('mall/slider')->with('success','删除成功');
    }
}
